﻿using com.iot.core.annotation; 
using com.iot.core.data;
using com.iot.ht.Controllers.htrole.data;
using com.iot.ht.Controllers.htrole.service;
using Microsoft.AspNetCore.Mvc; 

namespace com.iot.ht.Controllers.htrole
{
    [ApiController]
    [Route("[controller]/[action]")]
    [Tag(Name = "角色管理", Description = "")]
    public class HtRoleController : ControllerBase
    {
        private readonly IHtRoleService baseService;
        
        public HtRoleController(IHtRoleService p1)
        {
            baseService = p1;
        }


        [HttpPost]
        [Operation(Summary = "角色分页", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task<Page<HtRoleDto>> PageAsync([FromBody] BasePageDtQto mm)
        {
            var r = await baseService.PageAsync(mm);
            return r;
        }


        [HttpPost]
        [Operation(Summary = "角色详情", Description = "")]         
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task<HtRoleDto> DetailAsync(BaseQto qm)
        {
            return await baseService.DetailAsync(qm);
        }

        [HttpPost]
        [Operation(Summary = "插入角色初始化", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public HtRoleDto InsertInit( )
        {
            return   baseService.InsertInit( );
        }

 

        [HttpPost]
        [Operation(Summary = "添加角色", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Insert(HtRoleDto qm)
        {
            return baseService.Insert(qm);
        }

        [HttpPost]
        [Operation(Summary = "修改角色", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Update(HtRoleDto qm)
        {
            return baseService.Update(qm);
        }

        [HttpPost]
        [Operation(Summary = "删除角色", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Delete(BaseQto qm)
        {
            return baseService.Delete(qm);
        }

        [HttpPost]
        [Operation(Summary = "根据部门获取角色", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = true, LogPout = true, LogTemplete = "")]
        public List<IdNameDto> ListByDeptId(BaseQto qm)
        {
            return baseService.ListByDeptId(qm);
        }
    }
}
